﻿@model IEnumerable<Bk.Models.BlogInfo>

@{
    ViewBag.Title = "搜索结果";
}

<h1>搜索结果: @ViewBag.SearchTerm</h1>
<p>找到 @ViewBag.TotalCount 条结果</p>

<div class="blog-list">
    @foreach (var blog in Model)
    {
        <div class="blog-item">
            <h3>@blog.Title</h3>
            <p>@blog.Content.Truncate(100)</p>
            <small>发布于 @blog.CreatedAt.ToString("yyyy-MM-dd")</small>
        </div>
    }
</div>

<!-- 分页控件 -->
<div class="pagination">
    @for (int i = 1; i <= Math.Ceiling((double)ViewBag.TotalCount / ViewBag.PageSize); i++)
    {
        <a href="@Url.Action("Search", new { searchTerm = ViewBag.SearchTerm, page = i })"
           class="@(i == ViewBag.CurrentPage ? "active" : "")">
            @i
        </a>
    }
</div>